package com.nicolaspigelet.maps 
{
	import com.google.maps.interfaces.IOverlay;
	import com.google.maps.LatLng;
	import com.google.maps.overlays.Polygon;
	import com.google.maps.overlays.PolygonOptions;
	import com.google.maps.wrappers.IOverlayWrapper;
	
	/**
	 * @author Nicolas Pigelet aka tanaki
	 */
	public class CirclePoints
	{
		public var circleLatLngs:Array;
		
		public function CirclePoints(latLng:LatLng, radius:Number, numPoints:Number) {
			
			var d2r : Number = Math.PI / 180;
			circleLatLngs = new Array();
			
			// Convert statute miles into degrees latitude
			var circleLat : Number = radius * 0.014483;
			var circleLng : Number = circleLat / Math.cos(latLng.lat() * d2r);
			
			// Create polygon points (extra point to close polygon)
			for (var i : int = 0; i < numPoints + 1; i++) {
				// Convert degrees to radians
				var theta : Number = Math.PI * (i / (numPoints / 2));
				var vertexLat : Number = latLng.lat() + (circleLat * Math.sin(theta));
				var vertexLng : Number = latLng.lng() + (circleLng * Math.cos(theta));
				var vertextLatLng : LatLng = new LatLng(vertexLat, vertexLng);
				circleLatLngs.push(vertextLatLng);
			}
			
		}
	}

}